package com.ctgu.juc_project.config;

import com.ctgu.juc_project.JedisClusterFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class RedisClusterConfig {

    private List<String> hostPortList = new ArrayList<String>(){{
        add("127.0.0.1:7000");
        add("127.0.0.1:7001");
        add("127.0.0.1:7002");
        add("127.0.0.1:7003");
        add("127.0.0.1:7004");
        add("127.0.0.1:7005");
    }};

    @Bean(initMethod = "init", destroyMethod = "destroy")
    public JedisClusterFactory jedisClusterFactory(){
        JedisClusterFactory jedisClusterFactory = new JedisClusterFactory();
        jedisClusterFactory.setHostPortList(hostPortList);
        jedisClusterFactory.setTimeout(1000);
        return jedisClusterFactory;
    }
}
